#include <iostream>
#include <iomanip>

using namespace std;

int main_0023(void)
{
    int num = 0;
    cin >> num;

    int maxv = 0;
    int minv = 1000;
    int val = 0;

    for (int i = 0; i < num; ++i) {
        cin >> val;
        maxv = max(maxv, val);
        minv = min(minv, val);
    }

    if (num == 1) {
        cout << 0;
    } else {
        cout << maxv - minv;
    }

    return 0;
}
